home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / texte / 7up_pd / pcstrip.c < prev    next >
C/C++ Source or Header  |  1998-10-29  |  2KB  |  75 lines

  1. /* entfernt Symboltabelle (wenn das Pure-C Format passen täte) */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <ext.h>
  5.  
  6. typedef struct
  7. {
  8.     int  ph_branch; /*0x601A*/
  9.     long ph_tlen;
  10.     long ph_dlen;
  11.     long ph_blen;
  12.     long ph_slen;
  13.     long ph_res1;
  14.     long ph_prgflags;
  15.     int  ph_absflag;
  16. }PH;
  17.  
  18. int main(int argc, char *argv[])
  19. {
  20.    int fh;
  21.    char *cp;
  22.    PH *ph;
  23.     long slen, flen;
  24.     
  25.     if(argc == 2)
  26.     {   
  27.        if((fh=open(argv[1], O_RDONLY)) >= 0)
  28.        {
  29.          flen = filelength(fh);
  30.           if((cp=malloc(flen))!=NULL)
  31.           {
  32.               read(fh, cp, flen);
  33.               close(fh);
  34.                if((fh=open(argv[1], O_CREAT|O_TRUNC|O_WRONLY)) >= 0)
  35.               {
  36.                   ph = cp;
  37.                     printf("\nStripping %s\n",argv[1]);
  38.                     printf("\nT:%ld D:%ld B:%ld S:%ld ", 
  39.                                                  ph->ph_tlen, 
  40.                                      ph->ph_dlen, 
  41.                                      ph->ph_blen, 
  42.                                      ph->ph_slen);
  43.  
  44.                   slen = ph->ph_slen;
  45.                   ph->ph_slen = 0;
  46.                  
  47.                  write(fh, cp, sizeof(PH));
  48.                  cp += sizeof(PH);
  49.  
  50.                   write(fh, cp, ph->ph_tlen + ph->ph_dlen);
  51.                  cp += (ph->ph_tlen + ph->ph_dlen + slen);
  52.  
  53.                   write(fh, cp, (long)ph + flen - (long)cp);
  54.  
  55.                     printf("R:%ld\n", (long)ph + flen - (long)cp);
  56.  
  57.                   close(fh);
  58.                   free(ph); /* !!!! nicht cp */
  59.                    return(0);
  60.               }
  61.                else
  62.                     printf("\nCouldn't write %s\n", argv[1]);
  63.           }
  64.            else
  65.                 printf("\nNot enough memory to read %s\n", argv[1]);
  66.        }
  67.        else
  68.             printf("\nCouldn't open %s\n", argv[1]);
  69.    }
  70.    else
  71.         printf("\nUSAGE: pcstrip filename\n");
  72.    
  73.    return(-1);
  74. }
  75.